package com.cn.camundaappliction.controller;
import com.cn.camundaappliction.service.TaskService;
import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.camunda.bpm.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TestController {


    @Autowired
    private TaskService taskService;

    /**
     * 开启流程的方式
     */
    @PostMapping("/start/process/{key}")
    public void  startProcess(@PathVariable("key") String key){
        taskService.startProcess(key);
    }


    /**
     * 查询流程定义的方式
     * @return
     */
    @GetMapping("/process/def")
    public List<ProcessDefinition> findProcess(){
        return taskService.findProcess();
    }

    /**
     * 查询任务
     * @return
     */
    @GetMapping("/task")
    public List<Task> findTasks(){
        List<Task> tasks = taskService.findTasks();
        System.out.println("找到的任务的方式"+tasks.toString());
        return tasks;
    }

}